Computer systems generally operate upon binary data items that are anywhere between one and eight bytes in length, where a "byte" is defined as eight bits. Typically, the smallest data item that a modern computer system will operate on is either a "word", which is two bytes, or a "double-word" ("dword"), which is four bytes. For various different reasons, it is sometimes necessary or desirable to alter the order of bytes within a word or dword data item. This operation is known as "byte swapping". One possible reason byte swapping may be desirable, for example, is to switch back and forth between different methods of addressing data, such as between "little-endian" addressing, in which a memory address refers to the lowest-order byte of a data item, and "big-endian" addressing, in which an address specifies the highest-order byte of a data item.
In existing computer systems, byte swapping is generally performed by the host processor in response to software commands. Consider, for example, a common situation in which data stored in a block of memory is to be transferred to a new location (i.e., a different location in memory or a peripheral device) and in which byte swapping is required. The host processor would typically read the data from the memory, rearrange the bytes, and then write back the rearranged data words to the first block of memory. Then, the host would write the modified data words into the new location. This method has the disadvantage of being time-consuming, because the host processor must write back the modified data before transferring the data to the new location. Hence, what is needed is a faster and more efficient way to perform byte swapping during memory access operations.